Inside Macintosh: Macintosh Toolbox Essentials

Previous | Chapter Top | Chapter Contents | Next

Zooming Windows

This section describes the functions you can use to track mouse activity in the zoom box and to zoom windows.

TrackBox

Tracks the cursor when the user presses the mouse button while the cursor is in the zoom box.

pascal Boolean TrackBox (WindowPtr theWindow,
                     Point thePt,
                     short partCode);
theWindow
A pointer to the window record of the window in which the mouse button was pressed.
thePt
The location of the cursor when the mouse button was pressed. Your application receives this point from the where field in the event record.
partCode
The part code (either inZoomIn or inZoomOut ) returned by the FindWindow function (FindWindow) .

DESCRIPTION

The TrackBox function tracks the cursor when the user presses the mouse button while the cursor is in the zoom box, retaining control until the mouse button is released. While the button is down, TrackBox highlights the zoom box while the cursor is in the zoom region.

When the mouse button is released, TrackBox removes the highlighting from the zoom box and returns true if the cursor is within the zoom region and false if it is not.

Your application calls the TrackBox function when it receives a result code of either inZoomIn or inZoomOut from the FindWindow function (FindWindow) . If TrackBox returns true , your application calculates the standard state, if necessary, and calls the ZoomWindow function (ZoomWindow) to zoom the window. If TrackBox returns false , your application does nothing.

ASSEMBLY-LANGUAGE INFORMATION

You can set the global variable DragHook to point to an optional function, defined by your application, which will be called by TrackBox as long as the mouse button is held down. (If there's an actionProc function, the actionProc function is called first.) Note that the use of the Window Manager's global variables is not guaranteed to be compatible with system software versions later than System 6.

ZoomWindow

Zooms the window when the user has pressed and released the mouse button with the cursor in the zoom box.

pascal void ZoomWindow (WindowPtr theWindow,
                     short partCode,
                     Boolean front);
theWindow
A pointer to the window record for the window to be zoomed.
partCode
The result (either inZoomIn or inZoomOut ) returned by the FindWindow function (FindWindow) .
front
A Boolean value that determines whether the window is to be brought to the front. If the value of front is true , the window necessarily becomes the frontmost, active window. If the value of front is false , the window's position in the window list does not change. Note that if a window was active before it was zoomed, it remains active even if the value of front is false .

DESCRIPTION

The ZoomWindow function zooms a window in or out, depending on the value of the partCode parameter. Your application calls ZoomWindow , passing it the part code returned by FindWindow (FindWindow) , when it receives a result of true from TrackBox . The ZoomWindow function then changes the window's port rectangle to either the user state (if the part code is inZoomIn ) or the standard state (if the part code is inZoomOut ), as stored in the window state data record.

If the part code is inZoomOut , your application ordinarily calculates and sets the standard state before calling ZoomWindow .

For best results, call the QuickDraw function EraseRect , passing the window's graphics port as the port rectangle, before calling ZoomWindow .


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next